<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>常见问题</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
    <style type="text/css">
        .dis-none {
            display: none !important;
        }

        .close {
            display: inline-block !important;
            -webkit-transform: rotate(270deg);
            -moz-transform: rotate(270deg);
            -ms-transform: rotate(270deg);
            transform: rotate(270deg);
            transition: all .5s;
            -moz-transition: all .5s;
            -webkit-transition: all .5s;
            -o-transition: all .5s;
        }

        .open {
            display: inline-block !important;
            -webkit-transform: rotate(0deg);
            -moz-transform: rotate(0deg);
            -ms-transform: rotate(0deg);
            transform: rotate(0deg);
            transition: all .5s;
            -moz-transition: all .5s;
            -webkit-transition: all .5s;
            -o-transition: all .5s;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <div class="layui-tab layui-tab-brief">
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/help/help/commonProblemList.do" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo" value="${page.page}"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item-inline"><label class="search-form-lable">内容标题</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="title" autocomplete="off" class="layui-input"
                                                   value="${help.title}"
                                            >
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:submitFunction('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal"
                                               href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <div class="my-act-list-content">
                        <ul id="view">
                            <table class="layui-table" id="myTable">
                                <colgroup>
                                    <col>
                                    <col width="150">
                                    <col width="250">
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>标题</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="help" items="${helpList}">
                                    <c:set var="cHelp" value="${help}" scope="request"/>
                                    <jsp:include page="commonProblemTreeInclude.jsp"></jsp:include>
                                </c:forEach>
                                </tbody>
                            </table>
                        </ul>
                    </div>
                  <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<%@include file="../include/incScript.jsp" %>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    var element = null;
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use('element', function () {
            element = layui.element;

            element.on('tab', function (e) {
                $("#help_type").val(e.index);
                $("#myForm").submit();
            });
        });
    })
</script>
<script type="text/javascript">
    $(function () {
        $('#myTable').delegate('.icon-unfold', 'click', function (e) {
            var $option = $(e.target).closest('.option');
            var id = $option.data('id');
            var isClose = $option.find('.icon-unfold').hasClass('close');
            if (isClose) {
                $option.find('.icon-unfold').removeClass('close').addClass('open');
                $('#myTable').find('tr[data-parentid="' + id + '"]').removeClass('dis-none');
            } else {
                $option.find('.icon-unfold').addClass('close').removeClass('open');
                $('#myTable').find('tr[data-parentid="' + id + '"]').addClass('dis-none');
            }
        });
    });

    function addFirstCategory(helpId) {
        function cb($jquery) {
        }

        openDialog('${empty helpId ? '新增' : '编辑'}分类', '${ctx}/help/help/getHelpById.do?id=' + helpId, '500px', '300px', cb);
    }

    function openDialog(title, url, width, height, cb, target) {
        var index = layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }
            },
            cancel: function (index) {
            }
        });
    }

    txz.initHeader({
        nav: [{
            name: '常见问题',
            curr: true
        }],
        info: '<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        btns: [{
            name: '新增分类',
            icon: 'add',
            href: 'javascript:addFirstCategory(\'\')',
        }]
    });
</script>
</body>
</html>